package pattern.gateway.entity;
import lombok.Data;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;

/**
 * 日志返回信息
 * @author Simon
 * @since 2.0.0.0
 */
@Data
public class Log {
    private String hostName;
    private String ip;
    private String timeStamp;
    private String requestUrl;
    private String requestBody;
    private String responseBody;
    private String requestId;
    private String requestMethod;
    private Integer status;
    private String token;
    private String sessionId;


    public Log() {
        try {
            this.hostName = InetAddress.getLocalHost().getHostName();
            this.timeStamp = ZonedDateTime.now(ZoneOffset.of("+08:00")).toString();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String toString() {
        return "\n Log{" +
                "hostName='" + hostName + '\'' +
                ", ip='" + ip + '\'' +
                ", timeStamp='" + timeStamp + '\'' +
                ", requestUrl='" + requestUrl + '\'' +
                ", requestBody='" + requestBody + '\'' +
                ", responseBody='" + responseBody + '\'' +
                ", requestId='" + requestId + '\'' +
                ", requestMethod='" + requestMethod + '\'' +
                ", status=" + status +
                ", token='" + token + '\'' +
                ", sessionId='" + sessionId + '\'' +
                '}';
    }
}